# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

import os
import shutil

class Recipe(recipe.Recipe):
    """
    Ships the vapigen.m4 macro file from the vala tarball
    """
    name = 'vala-m4'
    version = '0.35.2'
    stype = SourceType.TARBALL
    url = 'gnome://vala/%(maj_ver)s/vala-%(version)s.tar.xz'
    tarball_dirname = 'vala-%(version)s'
    tarball_checksum = 'af5efb30e8a303dd1c211e2a30ba0b41e64d47c9d6c5271f1d8ffb4fb63a017f'
    licenses = [License.LGPLv2_1Plus]
    btype = BuildType.CUSTOM
    files_devel = ['share/aclocal/vala.m4', 'share/aclocal/vapigen.m4',
                   'share/vala/Makefile.vapigen']

    def install(self):
        shutil.copy(os.path.join(self.build_dir, 'vapigen', 'vapigen.m4'),
                        os.path.join(self.config.prefix, 'share',
                                     'aclocal', 'vapigen.m4'))
        shutil.copy(os.path.join(self.build_dir, 'vala.m4'),
                        os.path.join(self.config.prefix, 'share',
                                     'aclocal', 'vala.m4'))
        destdir = os.path.join(self.config.prefix, 'share', 'vala')
        if not os.path.exists(destdir):
            os.makedirs(destdir)
        shutil.copy(os.path.join(self.build_dir, 'vapigen', 'Makefile.vapigen'),
                    os.path.join(destdir, 'Makefile.vapigen'))
